import java.util.*;

public class CrashingBalloon {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine().trim();
            if (line.isEmpty()) continue;
            String[] tokens = line.split("\\s+");
            int a = Integer.parseInt(tokens[0]);
            int b = Integer.parseInt(tokens[1]);
            System.out.println(getWinner(a, b));
        }
        scanner.close();
    }

    public static int getWinner(int a, int b) {
        int maxNum = Math.max(a, b);
        int minNum = Math.min(a, b);
        List<Set<Integer>> listMax = new LinkedList<>();
        List<Set<Integer>> listMin = new LinkedList<>();
        // 判断合法性
        listMax = doDeCompose(maxNum, listMax, new HashSet<>(), 100);
        listMin = doDeCompose(minNum, listMin, new HashSet<>(), 100);
        if (listMin.isEmpty()) {
            return maxNum;
        } else {
            if (listMax.isEmpty())
                return minNum;
            else {
                if (hasUnion(listMin, listMax))
                    return minNum;
                else return maxNum;
            }
        }
    }

    //判断一个List<Set>是否和另一个List<Set>有交集
    public static boolean hasUnion(List<Set<Integer>> listA, List<Set<Integer>> listB) {
        if (listA.isEmpty() || listB.isEmpty()) return false;//无交集
        //        构造一个100大小全为1的数组
        int[] arr = new int[101];
        for (Set<Integer> setA : listA) {
            Arrays.fill(arr, 1);
            for (int i : setA) {
                if (i != 1)
                    arr[i] = 0;
            }
            for (Set<Integer> setB : listB) {
                int index = -1;
                for (int j : setB) {
                    index++;
                    if (arr[j] == 0) break;
                    else if (index == setB.size() - 1 && arr[j] == 1) {
                        return false;
                    }
                }
            }
        }
        return true;
    }

    public static List<Set<Integer>> doDeCompose(int num, List<Set<Integer>> resList, Set<Integer> set, int i) {
        if (num == 1) {
            resList.add(set);
        }

        // 判断能否根据1-100组成
        for (int m = Math.min(i, num); m >= 1; m--) {
            if (num % m == 0 && !set.contains(m)) {
                Set<Integer> nowSet = new HashSet<>(set);
                nowSet.add(m);
                doDeCompose(num / m, resList, nowSet, m - 1);
            }
        }
        return resList;
    }

}